package pack0701;
//try,catch 方法处理异常
import java.util.InputMismatchException;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入第一个数: ");
        while(true){
            try{
            int a = scan.nextInt();
            System.out.println("请输入第二个数: ");
            int b = scan.nextInt();
            System.out.println("除法的结果: " + a / b);
            break;
        }catch(InputMismatchException e){
            System.out.println("抓住了输入不匹配异常");
            scan = new Scanner(System.in);
            System.out.println("请重新输入第一个数: ");
        }catch(ArithmeticException e){
                System.out.println("抓住了数学异常");
                System.out.println("0不能做除数,请重新输入第一个数");
            }catch(Exception e){
                System.out.println("抓住了老大");
            }
        }
        System.out.println("计算完毕");




    }
}
